function checkPhone(val) {
  //手机号正则验证
  let reg = /^1[3456789]{1}\d{9}$/;
  if (reg.test(val)) {
    return true;
  } else {
    return false;
  }
}
function changeLine(str) {
  if (str) {
    return str.replace(/<br>/g, "\n");
  } else {
    return "";
  }
}
function getTime(time) {
  if (!time) {
    return "";
  }
  const y = time.getFullYear();
  const m =
    time.getMonth() < 9 ? `0${time.getMonth() + 1}` : time.getMonth() + 1;
  const d = time.getDate() < 10 ? `0${time.getDate()}` : time.getDate();
  const h = time.getHours() < 10 ? `0${time.getHours()}` : time.getHours();
  const f =
    time.getMinutes() < 10 ? `0${time.getMinutes()}` : time.getMinutes();
  const s =
    time.getSeconds() < 10 ? `0${time.getSeconds()}` : time.getSeconds();
  const str = `${y}-${m}-${d} ${h}:${f}:${s}`;
  return str;
}
function getDate(time) {
  if (!time) {
    return "";
  }
  const y = time.getFullYear();
  const m =
    time.getMonth() < 9 ? `0${time.getMonth() + 1}` : time.getMonth() + 1;
  const d = time.getDate() < 10 ? `0${time.getDate()}` : time.getDate();

  const str = `${y}-${m}-${d}`;
  return str;
}

export default {
  checkPhone,
  getTime,
  changeLine,
  getDate,
};
